//
// Created by Jisam on 2024/6/30.
//
#include <bits/stdc++.h>

#define i64 long long
using namespace std;
const int N = 5000 + 5;
const i64 M = 1e9 + 7;
i64 ans = 0;
int n;

int b[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    int x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        b[x]++;
    }
    for (int i = 1; i <= 5000; i++) {
        for (int j = i; j <= 5000; j++) {
            if (i + j > 5000) {
                break;
            }
            if(i==j)
            {
                if(b[i]>=2&&b[i<<1]>=2)
                    ans=(ans+(b[i]*(b[i]-1)/2LL%M*(b[i<<1]*(b[i<<1]-1)/2)%M))%M;
            }else{
                if(b[i]>=1&&b[j]>=1&&b[i+j]>=2)
                    ans=(ans+(b[i]*b[j]%M*(b[i+j]*(b[i+j]-1)/2)%M))%M;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}